class Car(val license: String, val brand: String, val color: String, var price: Int) {
  def drive(m: Int): Unit = {
    println("正在行驶！")
  }
  def stop(): Unit = {
    println("停车。")
  }
  def refuel(): Unit = {
    println("加油。")
  }
}

class ElectricCar(license: String, brand: String, color: String, price: Int, val battary: Int, var mile: Int) extends Car(license, brand, color, price) {

  override def drive(m: Int): Unit = {
    if (mile < m) {
      println("续航不够，无法驾驶，请充电！")
    } else {
      mile -= m
      println("行驶了" + mile + "英里！")
    }
  }

  override def stop(): Unit = {
    println("已停车！")
  }

  override def refuel(): Unit = {
    if (mile == battary) {
      println("电池容量已满，无需充电！")
    }
    mile = battary
    println("已完成充电！")
  }
}

val car = new ElectricCar("京A 23489", "品牌", "黑色", 2000000, 500, 500)
car.drive(200)
car.stop
car.drive(200)
car.stop
car.drive(300)
car.refuel
car.drive(300)
car.stop

